package com.hatch.ui
{
	import flash.events.MouseEvent;

	/**
	 * @author hatch
	 */
	public class RadioButton extends Button 
	{
		private var _state:String = 'off';

		public function RadioButton()
		{
			super();
		}

		override protected function addChildren():void
		{
			super.addChildren();
		}

		override public function draw():void
		{	
			super.draw();
			//trace('draw : state = ' + _state);
			gotoAndPlay(_state);
		}		

		//--------------------------------------
		//  Public Methods
		//--------------------------------------

		public function toggle():void
		{
			if(_state == 'off')
				this.state = 'on';
			else if(_state == 'on')
				this.state = 'off';
		}
		
		//--------------------------------------
		//  Private / Protected Methods
		//--------------------------------------
		
		override protected function onClick( event:MouseEvent = null):void
        {
        	if(!this.enabled) return;
        	super.onClick(event);
        	
        	toggle();
        }
	
		//--------------------------------------
		//  Handlers
		//--------------------------------------
 	
		
		//--------------------------------------
		//  Getters / Setters
		//--------------------------------------	

		public function set state(value:String):void
		{
			if(_state == value) return;
			_state = value;
			invalidate();
		}
	}
}
